package edu.cuit.avatar.map;

import java.util.LinkedHashMap;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/15 14:34
 */
public class LinkedHashMapTest {
    public static void main(String[] args) {
        //LinkedHashMap():按照插入顺序对key-value进行排序
        var map = new LinkedHashMap<Integer, String>();
        map.put(10, "Chengdu");
        map.put(20, "Beijing");
        map.put(30, "Nanjing");
        map.put(40, "Hangzhou");
        System.out.println(map);

        //按照最后访问顺序进行排序
        var map2 = new LinkedHashMap<Integer, String>(16,0.75f, true);
        map2.put(10, "Chengdu");
        map2.put(20, "Beijing");
        map2.put(30, "Nanjing");
        map2.put(40, "Hangzhou");

        System.out.println(map2.get(20));
        System.out.println(map2.get(30));
        System.out.println(map2);
    }
}
